package lt.ntec.danblog.server.core;


import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.servlet.ServletModule;
import com.google.inject.servlet.SessionScoped;
import lt.ntec.danblog.server.core.model.User;

public class CoreServletModule extends ServletModule {

    @Override
    protected void configureServlets() {

        bind(UserManager.class).to(GoogleUserManager.class);
        bind(MessageManager.class).to(SessionMessageManager.class).in(
                SessionScoped.class);
        bind(User.class).toProvider(UserProvider.class);
        bind(Config.class);

    }

    @Provides
    @Singleton
    UserService provideUserService() {
        return UserServiceFactory.getUserService();
    }

    @Provides
    com.google.appengine.api.users.User provideGoogleSysUser() {
        return provideUserService().getCurrentUser();
    }
}